﻿/// <reference path="underscore.js" />
(function () {
	var peopleArray = [
		{ firstname: "Ivan", lastname: "Ivanov" },
		{ firstname: "Kiril", lastname: "Ivanov" },
		{ firstname: "Ivan", lastname: "Kirilov" },
		{ firstname: "Ivan", lastname: "Ivanov" }
	];

	var groupedPeople = _.groupBy(peopleArray, function (person) {
		return person.firstname.toLocaleLowerCase() + person.lastname.toLocaleLowerCase();
	});

	var authorWithMostBooks = _.max(groupedPeople, function (person) {
		return person.length
	})[0];

	console.log("The most common first and last name: ");
	console.log(authorWithMostBooks);
})();